home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 25.1 KB | 687 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1992-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: VUAid.lib
- #
- # Version: 2.1.4
- #
- # Description:
- #
- # Contains:
- # VUAid()
- # IsVUAidInstalled()
- # VUAidReturnLongIntegers()
- #
- # launch_app()
- # whichCheckSum()
- # path()
- # pathq()
- # pathToList()
- # open_by_path()
- #
- # History:
- # Some of these tasks were originally found in 007, written by
- # EH and Alan Liu. Some have had minor changes, many
- # have had major changes. Some still use the names of their
- # predecessors but are entirely rewritten.
- # Date: By: Changes:
- # 05/01/92 Jason Marsh Clouseau 1.0 creation
- # 02/19/94 SBR Changed ControlPanels.lib to TargetControl.lib in Libraries.
- # 02/19/94 SBR Moved tasks to TargetControl: InstallVUAid(), sys_vers(),
- # sys7(), target_cpu(), CPUstic(), target_info()
- # 09/12/94 SBR Changes for VUAid 2.1.
- # 09/04/95 SBR Changes to VUAid().
- # 06/01/96 SBR/MSO Updated copyright header
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # 12/03/96 Masa changed call to abort_script(). Radar 1185040
- # 01/21/97 SBR Deleted older exception code and comments.
- #
- # Version Date Who Comments
- # ======= ======== === =================
- # 2.1.0 02/12/97 JAS Added 'vers' resources to library.
- # These should always match tool version when tool is revved.
- # 03/20/97 SBR IsVUAidInstalled() uses EnableProgramLinking().
- #
- #########################################################################
- #########################################################################
-
- Libraries
- "Clouseau.lib",
- "ExceptionHandling.lib",
- "Report.lib",
- "TargetControl.lib",
- "VUAid.tool";
-
- #########################################################################
- # task VUAid(command, parameterList, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Invokes the VUAid 2.1 external tool and requests a service.
- # Parameters: command: name of the service requested
- # parameterList: list of all the parameters to send
- # to the service
- # v_level: verbosity level for log output
- # Returns: Result returned by external tool.
- # If no result is expected, and there were no errors,
- # we return true;
- # If an error occurred, we return undefined.
- # Examples: checkSum := VUAid("CompareWindowRect", {10,10,30,30});
- # Assumptions: VU 2.1, VUAid 2.1 resides on target machine
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 12/23/92 Jon Marsh Total rework for VUAid 2.0
- # 12/15/93 Jay Loucks Convert parameterList to a list if
- # it is not. Fixed Radar 1121052.
- # 02/09/94 SBR Give non-list to VUAid directly.
- # 02/09/94 SBR Calculate card(parameterList) once.
- # 02/09/94 SBR Check first for no parameters (speed)
- # 09/04/95 SBR Use VU 2.1 switch for various size parameter lists
- #########################################################################
- task VUAid(command, parameterList := {}, v_level := 5)
- begin
- RStatus("VUAid: requesting {command} service from VUAid",v_level);
-
- if IsVUAidInstalled()
- begin
- #### SBR: moved no parameters case out here for speed (13 of 30 services)
- if parameterList = {}
- result := VUAid2(command);
-
- #### JDL: convert to a list if it is not a list
- #### SBR: move inside if IsVUAidInstalled() loop and give it to VUAid directly
- else if TypeOf(parameterList) <> 'list'
- result := VUAid2(command, parameterList);
-
- else
- begin
- #### SBR: calculate card(parameterList) once
- #### SBR: use switch statement
- paramListCard := card(parameterList);
- switch paramListCard
- begin
- case 1:
- result := VUAid2(command, parameterList[1]);
- case 2:
- result := VUAid2(command, parameterList[1], parameterList[2]);
- case 3:
- result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3]);
- case 4:
- result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3],
- parameterList[4]);
- case 5:
- result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3],
- parameterList[4], parameterList[5]);
- case 6:
- result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3],
- parameterList[4], parameterList[5], parameterList[6]);
- end;
- # if paramListCard = 1
- # result := VUAid2(command, parameterList[1]);
- # else if paramListCard = 4
- # result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3], parameterList[4]);
- # else if paramListCard = 2
- # result := VUAid2(command, parameterList[1], parameterList[2]);
- # else if paramListCard = 3
- # result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3]);
- # else if paramListCard = 5
- # result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3], parameterList[4], parameterList[5]);
- # else if paramListCard = 6
- # result := VUAid2(command, parameterList[1], parameterList[2], parameterList[3], parameterList[4], parameterList[5], parameterList[6]);
- end;
-
- if command = "Quit"
- global __gVUAid2Present := undefined;
- if RXStatus(v_level)
- println "VUAid tool returns: ", result, " for parameter list: ", parameterList;
- if result[1] = 0
- if IsUndefined(result[2])
- return true;
- else return result[2];
- end;
- return undefined;
- end;
-
- #########################################################################
- # task IsVUAidInstalled(reInit, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Determines if the VUAid 2.1 external tool is available
- # and launches and initializes if it isn't.
- # Parameters: reInit: true to re-initialize the tool (use if we
- # restarted the machine but still think the
- # tool is running - ha, ha)
- # v_level: verbosity level for log output
- # Returns: true if VUAid 2.1 is available,
- # false if the tool could not be found, launched or initialized.
- # Examples: IsVUAidInstalled(true);
- # Assumptions: VUAid 2.1
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 8/5/91 EH Creation as part of VUAidLib.vu for 007
- # 3/4/92 Jason Marsh Incorporated into Clouseau.Lib
- # 12/23/92 Jonathan Marsh Rewrote for VUAid 2.0
- # 02/15/94 SBR Added section to turn on Program Linking
- # 02/15/94 SBR Added check for -1224 or -1223 launch failures
- # 09/03/94 SBR Added error handling for target access
- # 09/14/94 SBR v_level at 5 to report VUAid still ready
- # 03/20/97 SBR Changed v_level to 5
- # 03/20/97 SBR Uses EnableProgramLinking().
- # 05/29/97 SBR Default v_level (1) for RError calls (was 2)
- #########################################################################
- task IsVUAidInstalled(reInit := false, v_level := 5)
- begin
- global __gVUAid2Present, g_VUAidReturnLongs;
-
- if isUndefined(__gVUAid2Present) or reInit
- begin
- VUAidWasInitialized := true;
- test4VUAid := VUAid2("Initialize", true);
- theScriptError := ScriptError();
- __gVUAid2Present := (test4VUAid[1] = 0);
-
- if theScriptError = -1223
- begin
- RError('IsVUAidlnstalled: VUAid external tool not found or failed to launch.');
- RError('IsVUAidlnstalled: Copy it to a hard disk and/or rebuild the desktop file.');
- end;
- else if theScriptError = -1224
- RError('IsVUAidlnstalled: External tool launch failed. Is there enough memory?');
- else if not __gVUAid2Present
- begin
- # Use the TargetControl.lib task to enable linking.
- EnableProgramLinking(true,true);
- end;
-
- test4VUAid := VUAid2("Initialize", true); # Finally, retry VUAid
- theScriptError := ScriptError();
- __gVUAid2Present := (test4VUAid[1] = 0) and (theScriptError = 0);
- end;
- if __gVUAid2Present
- begin
- if isUndefined(g_VUAidReturnLongs)
- rtnLongString := 'with default output types';
- else
- begin
- VUAid2('ReturnLongInts',g_VUAidReturnLongs);
- rtnLongString := assoc( g_VUAidReturnLongs, { {true,'to return long integers'},
- {false,'to return longInt strings'}});
- end;
-
- # 09/14/94 SBR report at v_level 5 unless VUAid was REALLY initialized
- if VUAidWasInitialized
- RStatus ("IsVUAidlnstalled: VUAid 2.1 was initialized {rtnLongString}.", v_level);
- else
- RStatus ("IsVUAidlnstalled: VUAid 2.1 is ready {rtnLongString}.", 5);
- end;
- else
- RError ("IsVUAidlnstalled: VUAid 2.1 initialization failed!", 2);
- return(__gVUAid2Present);
- end;
-
-
- #########################################################################
- # task VUAidReturnLongIntegers(returnLongs)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets up the global variable to store the g_VUAidReturnLongs
- # global. When IsVUAidInstalled() actually launches VUAid, it
- # uses the 'ReturnLongInts' service to ensure the values are
- # returned in the desired format.
- # Note: VU 2.0.x will convert longs from external tools to
- # strings, so this routine is useful only for a script
- # running under VU 2.1.
- # Parameters: returnLongs:
- # true: VUAid 2.1 returns long integers to VU
- # false: VUAid 2.1 returns longInt strings to VU
- # Returns: success: true
- # failure: false
- # Examples: VUAidReturnLongIntegers(true);
- # Assumptions: VU 2.1, VUAid 2.1
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/11/94 SBR Created
- # 03/20/97 SBR Changed v_level to 5
- #########################################################################
- task VUAidReturnLongIntegers(returnLongs := true, v_level := 5)
- begin
- global g_VUAidReturnLongs, __gVUAid2Present;
-
- g_VUAidReturnLongs := not not returnLongs; #coerce to Boolean type for assoc
- RStatus("VUAidReturnLongIntegers({g_VUAidReturnLongs}).", v_level);
-
- if __gVUAid2Present
- begin
- theResult := VUAid2('ReturnLongInts',g_VUAidReturnLongs);
- if theResult[1]
- begin
- RError("VUAidReturnLongIntegers: tool returned {theResult}.", 2);
- return false;
- end;
- end;
- return true;
- end;
-
-
- #########################################################################
- # task launch_app(appName, filesToOpen, exactNames, launchInForeground)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Open an application, without knowing its location in
- # the Finder. Open requested file(s) as well.
- # Parameters: None
- # Returns: Nothing
- # Examples: launch_app("TeachText", "ReadMe");
- # Assumptions: If there are multiple copies of an application you
- # will not know which one it will open. The same is
- # true of multiple 'fileToOpen' names in different
- # folders. The file will not necessarily be the one
- # in the same folder as the application, either. This
- # is a powerful launch tool, but use it carefully.
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 3/12/92 Jason Marsh Created as part of VUAid.Lib
- # 12/23/92 Jon Marsh Rewrote to call VUAid 2.0
- # 09/11/94 SBR added exactNames, launchInForeground
- #########################################################################
- task launch_app( appName, filesToOpen := "", launchInForeground := true,
- exactNames := true, v_level := 5 )
- begin
- if filesToOpen = "" # no file specified
- filesToOpen := {};
- else if typeOf(filesToOpen) <> 'list' # one file specified
- filesToOpen := {filesToOpen};
- # else multiple files assumed
- result := VUAid("Launch", {appName, filesToOpen, launchInForeground, exactNames}, v_level);
-
- if isUndefined(result)
- return false;
-
- if launchInForeground
- begin
- if await_presence([application t:appName],120)
- return RStatus("launch_app: launched {appName} in the foreground",v_level); #returns true always
- end;
- else
- begin
- processMenu := _Match([menuItem t:"Hide {_match([application]).t}"]).m.o;
-
- if await_presence([menuItem t:appName m:processMenu],120)
- return RStatus("launch_app: launched {appName} in the background",v_level); #returns true always
- end;
-
- return false;
- end;
-
-
- #########################################################################
- # task whichCheckSum(checkSumList, bitDepth, grays)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Returns the checksum from the list based on current bit-depth
- # Parameters: checkSumList: expected checksums, per bitdepth -
- # { 1bitcksum, 2bitcksum, 4bitcksum, 8bitcksum, 16bitcksum, 32bitcksum
- # [, grays2bitcksum, grays4bitcksum, grays8bitcksum]}
- # NOTE: greys values are optional, will assume values are the same for
- # grey and color if not present.
- # bitDepth: pass this in if you know it, as it will save execution time
- # greys: pass this in it you know it, as it will save execution time
- # Returns: Nothing
- # Examples: expected := whichCheckSum({'123','234','345','456','567'});
- # Assumptions: Uses VUAid to determine the current screen depth and grey setting
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 3/19/92 Jon Marsh Created
- # 6/9/92 Jason Marsh Updated for gray checksums
- #########################################################################
- task whichCheckSum(checkSumList, bitdepth := -1, grays := -1)
- begin
- if bitDepth = -1
- bitDepth := VUAid("GetDepth");
- if grays = -1
- grays := VUAid("GetGray");
- if grays = 1 and card checkSumList > 6
- begin
- if bitDepth = 8
- return checkSumList[9];
- else if bitDepth = 4
- return checkSumList[8];
- else if bitDepth = 2
- return checkSumList[7];
- end;
- else
- begin
- if bitDepth = 8
- return checkSumList[4];
- else if bitDepth = 16
- return checkSumList[5];
- else if bitDepth = 32
- return checkSumList[6];
- end;
-
- if bitDepth = 1
- return checkSumList[1];
- else if bitDepth = 4
- return checkSumList[3];
- else if bitDepth = 2
- return checkSumList[2];
- return ("unknown bit-depth");
- end;
-
-
- #########################################################################
- # task FlashRect(pRect, pNumFlashes, pTimeInverted)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Uses the VUAid InvertRect service to highlight a rectangle on the
- # screen. This is useful for developing scripts.
- # Parameters: pRect: Screen (global) rectangle
- # pNumFlashes: number of times to flash
- # pTimeInverted: milliseconds to stay in each state
- # # Returns: Nothing
- # Examples: FlashRect((match [control o:34]).r, 500, 4);
- # Assumptions: VU 2.1 for milliseconds parameter to wait task.
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/17/94 SBR created
- #########################################################################
- task FlashRect( pRect, pNumFlashes := 1, pTimeInverted := 500 )
- begin
- for pNumFlashes := pNumFlashes to 1 step -1
- begin
- VUAid("InvertScreenRect", pRect);
- wait(0,0,0,pTimeInverted);
- VUAid("InvertScreenRect", pRect);
- wait(0,0,0,pTimeInverted);
- end;
- end;
-
-
- #########################################################################
- # task pathToList(fullPathName)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: converts a pathname to a list of items
- # Parameters: fullPathName: full path name of format "Item1:Item2"
- # Returns: List of items in the path name. no Item will have a ":" in it.
- # Examples: pathList:= pathToList("Macintosh HD:Applications:TeachText");
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/12/92 Jason Marsh Created
- #########################################################################
- task pathToList(fullPathName)
- begin
- currentItem:= ""; #init variables
- pathList := {};
-
- for i:= 1 to card fullPathName
- begin
- temp := fullPathName[i];
- if temp = ":"
- begin
- pathList := insert(currentItem, card pathList + 1, pathList);
- currentItem := "";
- end;
- else
- CurrentItem := currentItem + temp;
- end;
-
- if currentItem <> "" #include the last item in case the path name didn't end with ":"
- pathList := insert(currentItem, card pathList + 1, pathList);
- return pathList;
- end;
-
-
- #########################################################################
- # task open_by_path(fullPathName, expectedDesc)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Open a window from the full path name of the file
- # Parameters: fullPathName: full path name of format "Item1:Item2"
- # NOTE: the path name is not the true 'system' path name,
- # but the apparent path name to the user. So, desktop
- # items are simply one item: i.e. the path name to the
- # trash is simply "Trash", not "Internal:Trash" or
- # "Internal:DeskTop:Trash"
- # expectedDesc: defaults to an open window of name "ItemN", but can be used
- # to check for the proper launch of an application, etc.
- # Returns: Nothing
- # Examples: ourFolder:= VUAid("FindFolder", {"font"}) + ":Times:Times";
- # open_by_path(ourFolder);
- # Assumptions: this routine inteligently checks to see what the orignal
- # open windows were, and leaves them open as it goes through
- # them
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/12/92 Jason Marsh Created
- # 11/09/93 Jay Loucks added elipsis to select_menuItem() call
- # to handle new exact match requirements
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task open_by_path(fullPathName, expectedDesc := [])
- begin
- rStatus("open_by_path: opening window " + fullPathName, 4);
- pathList := pathToList(fullPathName);
- if expectedDesc = []
- expectedDesc := [window t:pathList[card pathList]];
- try
- match [window t:$oldWindows];
- catch theError
- ExceptionDispatcher(theError,,{"match 1 in open_by_path()", {fullPathName, expectedDesc}});
- select_menuItem('About This Macintosh…');
- type_keys({'latch', commandKey, 'latch', shiftKey, UpArrowKey}); #make the desktop active
- vol:=pathList[1];
- _Type ({vol});
-
- select_window("About This Macintosh");
- type_keys({ 'down', commandKey, "w", "o", 'up', commandKey}); #opens the volume
-
- for i:= 2 to card pathList
- begin
- currentItem := pathList[i];
-
- type_Keys({currentItem, 'latch', commandKey, "i"});
- currentItem := currentItem + " info";
- if not await_presence([window t:currentItem],3,,,6)
- return RIncomplete("Incomplete: open_by_path failed to open path: {fullPathName}",3);
- key_eq("w"); #close 'info' window
-
- try
- match [window t:?currentWindow];
- catch theError
- ExceptionDispatcher(theError,,{"match 2 in open_by_path()", {fullPathName, expectedDesc}});
- if isMember(currentWindow, oldWindows)
- key_eq("o"); #don't close the source window
- else
- key_eq("o",5); #close the source window
- end;
-
- if not await_presence(expectedDesc,3,,,6)
- return RIncomplete("Incomplete: open_by_path failed to open path: {fullPathName}",3);
-
- return true;
- end;
-
-
- #########################################################################
- # task path(pathType, leafitem)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Provides a full HFS pathname based on the pathType parameter.
- # Parameters: pathType: returns a full pathname to:
- # (default) the top Finder window
- # 'Top Window' the top Finder window
- # 'Boot Volume' startup volume
- # 'Blessed' currently active System folder
- # 'Trash' Trash Folder on startup volume
- # 'Desktop' Desktop Folder on startup volume
- # 'Apple Menu Items' The special System sub-folders…
- # 'Control Panels'
- # 'Extensions'
- # 'Fonts'
- # 'Preferences'
- # 'PrintMonitor Documents' *** Not created on newly installed system
- # 'StartupItems'
- # 'Temporary Items' *** Not created on newly installed system
- # leafitem: optional item within the folder specified by pathType
- # Returns: success: full pathname of the specified item
- # failure: false
- # Examples: VUAid("move", {path('Blessed', thing), path('Apple Menu Items')});
- # VUAid("delete", {path('Apple Menu Items', thing)});
- # Assumptions: To be nice, the script closes all the windows it opens
- # along the way, unless they were already open. At the very
- # end, it attempts to select the windows so that they end up
- # in the same order they started (unless one is covered and
- # can't be clicked).
- # New Path Manager uses FindFolder module for all folders
- # except Top Window, which still requires the old command
- # up-arrow method. This initPaths() version calls
- # vuAid('FindFolder macs') and exits the entire script if
- # an error occurs.
- # Will not restore ordinals of folders with the same name
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/09/92 SBR Created
- # 05/11/92 SBR Incorporated new FindFolder VUaid module
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task path(pathType := 'Top Window', leafitem := '') begin
- global gPaths, bootVolume, gPathBlessed, pathBootVolume;
-
- if IsUndefined(gPaths)
- initPaths();
- oldSpeed := TypeSpeed(50);
-
- if pathType = 'Top Window'
- begin
- rStatus('Getting full pathname to the top window.', 4);
-
- if isUndefined(oldWindows)
- begin
- try
- match [window t:$oldWindows];
- catch theError
- ExceptionDispatcher(theError,,{"match 1 in path", {pathType, leafitem}});
- end;
-
- try
- match [window t:?windowName o:1]!;
- catch theError
- ExceptionDispatcher(theError,,{"match 2 in path", {pathType, leafitem}});
- if windowName = 'Desktop'
- pathname := VUAid("FindFolder", {"desk"});
- else
- begin
- bootVolume := VUAid("FindFolder", {"boot"});
- pathBootVolume := bootVolume + ':';
-
- pathname := '';
-
- while (windowName <> 'Desktop')
- begin
- previousName := windowName;
- pathname := windowName + ':' + pathname;
-
- if not(isMember(windowName, oldWindows))
- _PressKey ({optionKey});
- type_keys({'latch', commandKey, upArrowKey});
- _ReleaseKey ({optionKey});
- await_absence([window t:previousName o:1]);
- try
- match [window t:?windowName o:1]!;
- catch theError
- ExceptionDispatcher(theError,,{"match 3 in path", {pathType, leafitem}});
- end;
-
- if previousName <> bootVolume
- begin
- if previousName = 'Trash'
- pathname := pathBootVolume + pathname;
- else
- pathname := pathBootVolume + 'Desktop Folder:' + pathname;
- end;
- end;
-
- rStatus('Restoring previous window arrangement.', 4);
- numOldWinds := card(oldWindows);
- await_presence([window t:oldWindows[numOldWinds]]);
- for i := 0 to (numOldWinds-1)
- begin
- tempTitle := oldWindows[numOldWinds - i];
- if tempTitle <> 'Desktop'
- select_window(tempTitle);
- else
- type_keys({'latch', commandKey, 'latch', shiftKey, upArrowKey});
- end;
-
- rStatus('Finished getting full pathname to the top window.', 4);
- end;
-
- else
- begin
- PathList := {{'Boot Volume','boot'},
- {'Blessed',"macs"},
- {'Trash' ,"trsh"},
- {'Desktop', "desk"},
- {'Apple Menu Items', "amnu"},
- {'Control Panels', "ctrl"},
- {'Extensions', "extn"},
- {'Fonts', "font"},
- {'Preferences', "pref"},
- {'PrintMonitor Documents', "prnt"},
- {'Startup Items', "strt"},
- {'Temporary Items', "temp"}};
-
- temp := assoc(pathType,PathList);
-
- if not temp
- RIncomplete('Path was given an undefined pathType: ' + pathType);
- else
- begin
- pathName := VUAid("FindFolder", {temp});
- if IsUndefined(pathName)
- return RIncomplete("VUAid FindFolder returned an error");
- if leafItem <> ''
- pathName := pathName + ":";
- end;
- end;
-
- TypeSpeed(oldSpeed);
-
- return pathname + leafItem;
- end;
-
-
- #########################################################################
- # task initPaths(restoreWindows)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets up the global variables necessary for path() to
- # operate. Usually not called by scripters, it gets
- # called by path() if gPaths is undefined.
- # Parameters: restoreWindows: caller puts a false here if it intends
- # to restore windows
- # Returns: success: a list of the currently open windows before initializing
- # failure: false
- # Examples: initPaths();
- # Assumptions: Does not work with international systems
- # Will not restore ordinals of folders with the same name
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/09/92 SBR Created
- # 12/03/96 Masa changed call to abort_script(). Radar 1185040
- #########################################################################
- task initPaths(restoreWindows := true) begin
- if IsUndefined(global gPathsOK)
- begin
- rStatus('Initializing the Path Manager.', 4);
-
- oldSpeed := TypeSpeed(50);
- if not VUAid("FindFolder", {"macs"})
- begin
- rError("Fatal error: Path Manager startup failed. Check VUAid for FindFolder module?");
- abort_script("initPaths: Path Manager startup failed. Check VUAid for FindFolder module?");
- end;
-
- TypeSpeed(oldSpeed);
- global gPathsOK := true;
- rStatus('Finished initializing the Path Manager', 4);
- return true;
- end;
- end;
-
-